package com.atguigu.edu.realtime.util;

import org.wltea.analyzer.core.IKSegmenter;
import org.wltea.analyzer.core.Lexeme;

import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;

/**
 * @author Lec
 * @date 2022/8/23 18:52
 */

public class KeywordUtil {
    public static List<String> analyze(String s) {
        ArrayList<String> result = new ArrayList<>();
        StringReader stringReader = new StringReader(s);
        IKSegmenter ikSegmenter = new IKSegmenter(stringReader, true);
        Lexeme next = null;
        try {
            while ( (next = ikSegmenter.next()) != null) {
                result.add(next.getLexemeText());
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return result;
    }


    public static void main(String[] args) {
        System.out.println(analyze("山东菏泽曹县牛逼666，我嘞宝贝"));
    }
}
